package work;

import java.util.Scanner;

/*
2 编程, 求一个数的阶乘
      7 !  =7*6*5*4*3*2*1
 */
public class Work02 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要求阶乘的数：");
        int num = scanner.nextInt();
        print(num);
        int sum = jiecheng(num);
        System.out.println(num+"的阶乘为"+sum);
    }
    static int jiecheng(int num){
        int sum = 1;
        for (int i = 1; i <= num; i++) {
            sum *=i;
        }
        return sum;
    }
    static void print(int num){
        System.out.print(num+"!="+num);
        for (int i = num-1; i >= 1; i--) {
            System.out.print("*"+i);
        }
        System.out.println();
    }
}
